<template>
    <div id="check-result">
        <div style="padding-top: 5px" class="borderStyle">
            <el-form label-width="80px" size="mini" ref="queryForm" :model="queryForm">
                <el-row>
                    <el-col :span="6">
                        <el-form-item label="招标日期">
                            <el-date-picker
                                v-model="BidDateRange"
                                type="daterange"
                                value-format="yyyyMMdd"
                                range-separator="-"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                size="small"
                                style="min-width: 210px; width: 20vw"
                                @change="handleIssueData"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="证券">
                            <el-select
                                v-model="queryReqVO.bondCode"
                                filterable
                                remote
                                clearable
                                :remote-method="getBondCodeList"
                                :loading="selectLoading"
                                @change="handleBondCodeList"
                                size="mini"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in bondCodeSelectData"
                                    :key="item.dictKey"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                    :value="item.dictKey"
                                >
                                </el-option>
                            </el-select>
                            <!-- <RiskCustomSelect
                                :selectKeys="queryReqVO.bondCode"
                                :dataSource="name.bondCode"
                                showSelectAll="false"
                                :showSearch="name.bondCode && name.bondCode.length != 0"
                                :key="'renderPrimaryBondNum' + renderPrimaryBondNum"
                                @customSelectReturn="customSelectReturn($event, 'bondCode')"
                            ></RiskCustomSelect> -->
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="产品">
                            <el-select v-model="queryReqVO.fundCode" filterable size="mini" multiple collapse-tags>
                                <el-option
                                    v-for="item in name.fundSelect"
                                    :key="item.dictKey"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                    :value="item.dictKey"
                                >
                                </el-option>
                            </el-select>
                            <!-- <RiskCustomSelect
                                :dataSource="name.fundSelect"
                                showSearch="true"
                                :selectKeys="queryReqVO.fundCode"
                                @customSelectReturn="customSelectReturn($event, 'fundCode')"
                                :key="renderPrimaryFundNum + 'renderPrimaryFundNum'"
                            ></RiskCustomSelect> -->
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="发行人">
                            <el-select
                                v-model="queryReqVO.issueCode"
                                filterable
                                clearable
                                remote
                                :remote-method="getIssueCodeList"
                                :loading="selectLoading"
                                @change="handleIssueCodeList"
                                size="mini"
                                multiple
                                collapse-tags
                            >
                                <el-option
                                    v-for="item in issueCodeSelectData"
                                    :key="item.dictKey"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                    :value="item.dictKey"
                                >
                                </el-option>
                            </el-select>
                            <!-- <RiskCustomSelect
                                :selectKeys="queryReqVO.issueCode"
                                :dataSource="name.issueCode"
                                showSelectAll="false"
                                :showSearch="name.issueCode && name.issueCode.length != 0"
                                :key="'renderPrimaryBondIssueNum' + renderPrimaryBondIssueNum"
                                @customSelectReturn="customSelectReturn($event, 'issueCode')"
                            ></RiskCustomSelect> -->
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="6">
                        <el-form-item label="下达日期">
                            <el-date-picker
                                v-model="directDate"
                                type="daterange"
                                range-separator="-"
                                value-format="yyyyMMdd"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                size="small"
                                style="min-width: 210px; width: 20vw"
                                @change="handleDirectDate"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="下达人">
                            <!-- <RiskCustomSelect
                                :dataSource="name.userSelect"
                                showSearch="true"
                                :selectKeys="queryReqVO.userName"
                                @customSelectReturn="customSelectReturn($event, 'userName')"
                                :key="renderPrimaryuserNum + 'renderPrimaryuserNum'"
                            ></RiskCustomSelect> -->
                            <el-select v-model="queryReqVO.userName" filterable clearable size="mini" multiple collapse-tags>
                                <!-- <el-option
                                    v-for="item in name.userSelect"
                                    :key="item.dictKeyName"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                    :value="item.dictKeyName"
                                >
                                </el-option> -->
                                <el-option
                                    v-for="item in name.userSelect"
                                    :key="item.dictKey"
                                    :value="item.dictCode"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="投标状态">
                            <el-select v-model="queryReqVO.instructionStatus" size="mini" clearable>
                                <el-option
                                    v-for="item in instructionStatusType"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKeyName"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label-width="40px">
                            <el-checkbox v-model="queryReqVO.isMyBidInst">仅显示我的投标指令</el-checkbox>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row style="text-align: end; padding: 0 5px 5px 0">
                    <el-button type="primary" @click="handleButton('search')">查询</el-button>
                    <el-button @click="handleButton('reset')">重置</el-button>
                    <el-button type="primary" @click="layoutDialog = true" icon="el-icon-setting">页面布局</el-button>
                </el-row>
            </el-form>
        </div>
        <div class="main">
            <div>
                <el-table
                    @row-click="handleRow"
                    :row-style="{ height: '35px' }"
                    :header-row-style="{ height: '40px' }"
                    :cell-style="{ padding: '0px', borderColor: '#d7d7d7' }"
                    :header-cell-style="{ borderColor: '#d7d7d7', 'text-align': 'center' }"
                    show-overflow-tooltip
                    highlight-current-row
                    highlight-hover-row
                    border
                    stripe
                    ref="xTable"
                    resizable
                    :data="tableData"
                    :key="tableDataBidManageNumKey + 'tableDataBidManageNumKey'"
                    v-loading="tableDataBidManageLoading"
                    height="calc(100vh - 430px)"
                    style="min-height: 60px"
                    :default-sort="{ prop: sortProp, order: sortOrder }"
                    @sort-change="changeTableSort"
                >
                    <template v-for="(item, index) in showFieldList">
                        <el-table-column
                            show-overflow-tooltip
                            :key="index"
                            :label="item.content"
                            :prop="item.id"
                            :min-width="item.minWidth"
                            :sortable="'custom'"
                            :sort-orders="['ascending', 'descending']"
                        >
                            <template slot-scope="scope">
                                <span
                                    v-if="item.id === 'payDate' || item.id === 'listDate' || item.id === 'bidStartDate' || item.id === 'bidEndDate'"
                                    style="display:block; text-align:center"
                                >
                                    {{ dateFormat(scope.row[item.id]) || '--' }}
                                </span>

                                <span v-else-if="item.id === 'directDate'" style="display:block; text-align:center">
                                    {{ dateFormat(scope.row[item.id]) }}
                                    {{ timeFormat(scope.row.directTime) }}
                                </span>

                                <span v-else-if="item.id === 'issueNature'" style="display:block; text-align:center">{{
                                    dataRander(scope.row)
                                }}</span>

                                <span v-else-if="item.id === 'compGrade'">
                                    <span v-if="scope.row.compGrade && scope.row.debtRating">{{
                                        scope.row.compGrade + '/' + scope.row.debtRating
                                    }}</span>
                                    <span v-else-if="scope.row.compGrade && !scope.row.debtRating">{{ scope.row.compGrade + '/' + '空' }}</span>
                                    <span v-else-if="!scope.row.compGrade && scope.row.debtRating">{{ '空' + '/' + scope.row.debtRating }}</span>
                                    <span v-else>{{ '--' }}</span>
                                </span>

                                <span v-else-if="item.id == 'direactUser'">
                                    {{ getDirectUser(scope.row[item.id]) }}
                                </span>

                                <span v-else-if="item.id === 'instructionStatus'">
                                    <span v-if="scope.row.instructionStatus === '2'">已归档</span>
                                    <span v-if="scope.row.instructionStatus === '1'">已下达成功</span>
                                    <span v-if="scope.row.instructionStatus === '3'">已撤销</span>
                                </span>
                                <span v-else>{{
                                    scope.row[item.id] === 0 || (scope.row[item.id] && (scope.row[item.id] + '').trim()) ? scope.row[item.id] : '--'
                                }}</span>
                            </template>
                        </el-table-column>
                    </template>

                    <el-table-column label="操作" show-overflow min-width="100" fixed="left">
                        <template slot-scope="scope">
                            <!-- <el-button
                                type="text"
                                size="mini"
                                @click.stop="handleRowButton(scope.row, 'update')"
                                :disabled="handleDisabled(scope.row)"
                                >修改</el-button
                            > -->
                            <el-button
                                type="text"
                                size="mini"
                                :disabled="handleDisabled(scope.row)"
                                @click.stop="handleRowButton(scope.row, 'delete')"
                                >撤单</el-button
                            >
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="block">
                <el-pagination
                    background
                    @current-change="getBidTableData"
                    layout="total, prev, pager, next"
                    :total="page.total"
                    :page-size="page.pageSize"
                    :current-page.sync="page.currentPage"
                    v-show="tableData.length > 0"
                ></el-pagination>
            </div>
        </div>
        <div class="main-bottom">
            <span style="font-size: 16px">产品信息:</span>
            <el-table
                show-overflow
                stripe
                border
                ref="fundInfoTable"
                resizable
                width="100%"
                height="140px"
                style="border-top: 1px solid #ccc"
                :data="tableDataFundInfo"
                :key="tableDataFundInfoNumKey + 'tableDataFundInfoNumKey'"
                v-loading="tableDataFundInfoLoading"
                :row-style="{ height: '35px' }"
            >
                <el-table-column prop="fundCode" label="产品编号" min-width="100" show-overflow-tooltip></el-table-column>
                <el-table-column prop="fundNameSt" label="产品名称" min-width="100" show-overflow-tooltip> </el-table-column>
                <!-- <el-table-column prop="assetCode" label="资产单元编号" min-width="140" show-overflow-tooltip v-if="SHOW_SECURITY">
                    <template slot-scope="scope">
                        <span>{{ scope.row.assetCode || '--' }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="assetName" label="资产单元名称" min-width="140" show-overflow-tooltip v-if="SHOW_SECURITY">
                    <template slot-scope="scope">
                        <span>{{ scope.row.assetName || '--' }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="fundAccountCode" label="组合编码" min-width="100" show-overflow-tooltip v-if="SHOW_SECURITY">
                    <template slot-scope="scope">
                        <span>{{ scope.row.fundAccountCode || '--' }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="fdAcName" label="组合名称" min-width="100" show-overflow-tooltip v-if="SHOW_SECURITY">
                    <template slot-scope="scope">
                        <span>{{ scope.row.fdAcName || '--' }}</span>
                    </template>
                </el-table-column> -->
                <el-table-column prop="bidSubject" label="招标标的" min-width="130" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span v-if="scope.row.bidSubject === '1'">利率</span>
                        <span v-else-if="scope.row.bidSubject === '3'">价格</span>
                        <span v-else>--</span>
                    </template>
                </el-table-column>
                <el-table-column prop="instPrice" label="利率(%)/价格(元)" min-width="160" show-overflow-tooltip align="right">
                    <template #default="{ row }">
                        {{ row.instPrice != undefined ? numberFormat(row.instPrice, 2) : '--' }}
                    </template>
                </el-table-column>
                <el-table-column prop="instBalance" label="投标金额(万元)" min-width="180" show-overflow-tooltip align="right">
                    <template #default="{ row }">
                        {{ row.instBalance != undefined ? numberFormat(row.instBalance, 4) : '--' }}
                    </template>
                </el-table-column>
                <el-table-column prop="tenderWay" label="投标方式" min-width="120px">
                    <template #default="{ row }">
                        {{ row.tenderWay === '3' ? '上市买入' : row.tenderWay == 'K' ? '一级缴款' : '--' }}
                    </template>
                </el-table-column>
                <el-table-column prop="summary" label="备注" min-width="80" show-overflow-tooltip>
                    <template #default="{ row }">
                        {{ row.summary || '--' }}
                    </template>
                </el-table-column>
                <el-table-column prop="direactUser" label="操作员" min-width="200" show-overflow-tooltip>
                    <template #default="{ row }">
                        {{ getDirectUser(row['direactUser']) }}
                    </template>
                </el-table-column>
                <el-table-column label="操作时间" min-width="160" align="center">
                    <template #default="{ row }">
                        {{ getDataTime(row) }}
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <!-- 投标详情 -->
        <BidDetail
            :bidDetailShow="updateRowShow"
            :rowData="rowData"
            @bidDetailReturn="bidDetailReturn"
            v-if="updateRowShow"
            isUpdate="true"
        ></BidDetail>

        <!-- 页面布局 -->
        <RiskTableLayout
            title="页面布局"
            :visible.sync="layoutDialog"
            :field-list="tableColumns"
            :selected-field-list="selectedFieldList"
            :fixed-field-list="fixedFieldList"
            table-name="PRIMARY_BOND_BID"
            @on-submit="onSubmit"
        />
    </div>
</template>
<script lang="ts">
import RiskCustomSelect from '@/common/components/risk-custom-select.vue';
import RiskIconButton from '@/common/components/risk-icon-button.vue';
import { Component, Vue } from 'vue-property-decorator';
import * as moment from 'moment';
import { dateFormat, PrefixInteger, timeFormat, numberFormat, UUID, getConfigItem } from '@/utils/tools';
import BidDetail from './bid-detail.vue';
import RiskTableLayout from '@/common/components/risk-table-layout.vue';
import { cancelSeniorBondOrder } from '@/common/api/instruction';
import { getUser } from '@/utils/user-util';
import ColumnUtil from '../utils/column-util';

@Component({
    name: 'BiddingManage',
    components: {
        RiskIconButton,
        RiskCustomSelect,
        BidDetail,
        RiskTableLayout,
    },
})
export default class BiddingManage extends Vue {
    dateFormat = dateFormat;
    timeFormat = timeFormat;
    numberFormat = numberFormat;
    SHOW_SECURITY = getConfigItem('SHOW_SECURITY');
    ColumnUtil = new ColumnUtil();
    private tableDataBidManageNumKey: number = -1; // 表格渲染

    private tableDataBidManageLoading: boolean = false; // 表格加载

    private tableData: any[] = []; // 表格数据

    private tableDataFundInfo: any[] = []; // 产品表格信息

    private tableDataFundInfoNumKey: number = -1; // 产品表格渲染

    private tableDataFundInfoLoading: boolean = false; // 产品表格加载

    private BidDateRange: any[] = []; // 发行日期显示值

    private directDate: any[] = []; // 下达日期显示值

    private renderPrimaryBondNum: number = -1; // 证券下拉选择渲染Key

    private renderPrimaryBondIssueNum: number = -1; // 发行人下拉选择渲染Key

    private renderPrimaryFundNum: number = -1; // 产品下拉选择渲染Key

    private renderPrimaryuserNum: number = -1; // 下达人下拉选择渲染Key

    private selectLoading: boolean = false; // 下拉框远程搜索时的加载状态

    private bondCodeSelectData: any[] = []; // 债券代码下拉框数据

    private issueCodeSelectData: any[] = []; // 发行人代码下拉框数据

    private page = {
        total: 0,
        currentPage: 1,
        pageSize: 25,
    };

    private queryReqVO: any = {}; // 查询请求参数

    private queryReqVOModal: any = {
        //   发行日期开始
        BidStartDate: 0,
        //   发行日期结束
        BidEndDate: 0,
        // 下达日期开始
        directDateStart: 0,
        //  下达日期结束
        directDateEnd: 0,
        //  证券代码
        bondCode: [],
        //   下达人
        userName: [],
        //   产品代码
        fundCode: [],
        //   发行人代码
        issueCode: [],
        //   仅显示我的投标指令
        isMyBidInst: false,
        //   投标状态
        instructionStatus: '',
        sort: '',
        // 1.已下达成功 2.已归档 3.已撤销
    };

    // 保存可下拉选择数据
    private name: any = {
        bondCode: [],
        issueCode: [],
        userSelect: [],
        fundSelect: [],
    };

    // 投标状态
    private instructionStatusType: any[] = [
        {
            dictKey: '1',
            dictKeyName: '已下达成功',
        },
        {
            dictKey: '2',
            dictKeyName: '已归档',
        },
        {
            dictKey: '3',
            dictKeyName: '已撤销',
        },
    ];

    private rowData: any = {}; // 修改行点击

    private updateRowShow: boolean = false; // 投标修改页面是否展示

    // 已选择字段列表
    selectedFieldList: any[] = [];

    // 固定字段列表
    fixedFieldList: any[] = [
        { content: '债券简称', id: 'bondNameSt', minWidth: '110px' },
        { content: '债券代码', id: 'bondCode', minWidth: '110px' },
        { id: 'bidStartDate', content: '投标日期', minWidth: '110px' },
        { id: 'bidEndDate', content: '投标截止日期', minWidth: '130px' },
    ];

    // 要显示的表格列
    showFieldList: any[] = [];

    // 布局是否显示
    private layoutDialog: boolean = false;

    // 全部表格列
    private tableColumns: any[] = [
        { id: 'bidNo', content: '投标序号', minWidth: '110px' },
        { id: 'bondNameSt', content: '债券简称', minWidth: '110px' },
        { id: 'bondCode', content: '债券代码', minWidth: '110px' },
        { id: 'instBalance', content: '投标金额(万元)', minWidth: '140px' },
        { id: 'marketName', content: '交易市场', minWidth: '110px' },
        { id: 'bidStartDate', content: '投标日期', minWidth: '110px' },
        { id: 'bidEndDate', content: '投标截止日期', minWidth: '130px' },
        { id: 'payDate', content: '缴款日期', minWidth: '110px' },
        { id: 'listDate', content: '上市日期', minWidth: '110px' },
        { id: 'totalBalance', content: '发行规模(亿)', minWidth: '130px' },
        { id: 'bondType', content: '债券类别', minWidth: '110px' },
        { id: 'compGrade', content: '信用评级(主体/债券)', minWidth: '180px' },
        { id: 'issueName', content: '发行人', minWidth: '110px' },
        { id: 'issueNature', content: '发行人性质', minWidth: '130px' },
        { id: 'direactUser', content: '下达人', minWidth: '110px' },
        { id: 'directDate', content: '下达时间', minWidth: '110px' },
        { id: 'instructionStatus', content: '投标状态', minWidth: '110px' },
    ];
    // todo   产品代码和产品名称
    sortParams = {
        bondNameSt: 'C_BOND_NAME_ST',
        bidNo: 'C_BID_NO',
        bondCode: 'C_BOND_CODE',
        instBalance: 'N_INST_BALANCE',
        marketName: 'C_MARKET_NAME',
        bidStartDate: 'D_BIDSTART_DATE',
        bidEndDate: 'D_BIDCLOSE_DATE',
        payDate: 'D_PAYDATE',
        listDate: 'D_LIST_DATE',
        totalBalance: 'N_TOTAL_BALANCE',
        bondType: 'C_BOND_TYPE',
        issueName: 'C_ISSUE_NAME',
        issueNature: 'C_ISSUE_TYPE3',
        direactUser: 'C_DIREACT_USER',
        instructionStatus: 'C_INST_STATUS',
    };

    // 排序字段
    private sortProp: string = '';
    // 排序方式
    private sortOrder: string = '';
    async mounted() {
        this.queryReqVO = JSON.parse(JSON.stringify(this.queryReqVOModal));
        this.getSelectValue();
        this.getBidTableData(1);

        this.getBondCodeList('');
        this.getIssueCodeList('');
        this.queryLayout();
    }

    beforeUpdate() {
        this.$nextTick(() => {
            // 在数据加载完，重新渲染表格
            (this.$refs['xTable'] as any).doLayout();
        });
    }

    // 获取页面布局信息
    async queryLayout() {
        let resList: any = await new Promise((resolve, reject) => {
            this.$axios('/tableLayout/query/PRIMARY_BOND_BID')
                .then((res: any) => {
                    resolve(res);
                })
                .catch(err => {
                    reject(err);
                });
        });
        if (resList) {
            this.selectedFieldList = JSON.parse(resList);
            this.showFieldList = this.fixedFieldList.concat(this.selectedFieldList);
        } else {
            this.selectedFieldList = this.tableColumns;
            this.showFieldList = this.fixedFieldList.concat(this.selectedFieldList);
        }
    }

    // 下达人
    private getDirectUser(value: any): any {
        let actual = this.name.userSelect.find(item => item.dictCode == value || item.dictKey == value) || {};
        return value ? actual.dictKeyName : '--';
    }

    /**
     * 提交成功后回调
     * @param {Object} 回调数据
     */
    async onSubmit(data) {
        await this.queryLayout();
    }

    // 排序改变
    private changeTableSort(column): void {
        this.sortProp = column.prop;
        this.sortOrder = column.order;
        let sortType = column.order == 'ascending' ? 'ASC' : column.order == 'descending' ? 'DESC' : '';
        this.queryReqVO.sort = this.findName(column.prop, sortType);
        this.getBidTableData(this.page.currentPage);
    }

    // 获取排序字段名称
    private findName(name: string, order: string): string {
        if (name == 'compGrade') {
            return 'C_ISSUE_GRADE' + ' ' + order + ',' + 'C_BOND_GRADE' + ' ' + order;
        } else if (name == 'directDate') {
            return 'D_DIRECT_DATE' + ' ' + order + ',' + 'D_DIRECT_TIME' + ' ' + order;
        } else {
            return this.sortParams[name] + ' ' + order;
        }
    }

    // 获取表格数据
    private getBidTableData(curPage: number): void {
        this.tableDataFundInfo = [];
        this.tableDataBidManageLoading = true;
        this.page.currentPage = curPage;
        this.$axios
            .post('/primaryBond/bidManager/list', {
                ...this.queryReqVO,
                paging: {
                    currentPage: this.page.currentPage,
                    pageSize: this.page.pageSize,
                },
            })
            .then((res: any) => {
                this.tableData = res.list;
                this.page.total = res.total;
                this.tableDataBidManageNumKey++;
                this.tableDataBidManageLoading = false;
            })
            .catch(() => {
                this.tableData = [];
                this.page.total = 0;
                this.tableDataBidManageLoading = false;
            });
    }

    // 点击行
    private handleRow(row): void {
        this.tableDataFundInfoLoading = true;
        this.$axios.get('/primaryBond/bidManager/fundList/' + row.instNo + '/' + row.instructionStatus).then((res: any) => {
            this.tableDataFundInfo = res;
            this.tableDataFundInfoNumKey++;
            this.tableDataFundInfoLoading = false;
        });
    }

    // 产品代码，下达人多选框数据源
    private getSelectValue(): void {
        this.$axios({
            url: '/instruction/user/select',
            method: 'post',
        }).then((res: any) => {
            this.name.userSelect = res;
            this.renderPrimaryuserNum++;
        });

        this.$axios({
            url: '/primaryBond/select',
            method: 'get',
        }).then((res: any) => {
            for (let fundInfo of res.fundSelect || []) {
                this.name.fundSelect.push({
                    dictKey: fundInfo.code,
                    dictKeyName: fundInfo.name,
                });
            }
            this.name.fundSelect.sort((a, b) => {
                return parseInt(a.dictKey) - parseInt(b.dictKey);
            });
            this.renderPrimaryFundNum++;
        });
    }

    // 按钮操作
    private handleRowButton(row: any, type: string): void {
        this.rowData = row;
        if (type == 'update') {
            this.updateRowShow = true;
        } else {
            this.$confirm('确认是否撤单?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    this.cancelOrder();
                })
                .catch(() => {
                    this.yh_message_info('已取消撤单');
                });
        }
    }

    // 撤单
    private cancelOrder(): void {
        this.$axios
            .post('/dataEngine/order/seniorBond/cancelOrder', {
                cancelOrderType: '1',
                tradeUser: getUser().userCode, // 当前用户
                tradeUserName: getUser().userName, // 当前用户
                orderType: '4',
                instructionType: '10',
                instNo: this.rowData.instNo,
                originOuterOrderCode: this.rowData.originOuterOrderCode,
                serialNo: this.rowData.serialNo,
                outerOrderCode: UUID() + '-' + new Date().getTime(),
                requestId: UUID() + '-' + new Date().getTime(),
            })
            .then((res: any) => {
                this.yh_message_success('撤单成功');
                this.getBidTableData(1);
            })
            .catch(() => {
                this.yh_message_error('撤单失败');
            });
    }

    // 处理发行日期
    private handleIssueData() {
        if (this.BidDateRange) {
            this.queryReqVO.BidStartDate = this.BidDateRange[0];
            this.queryReqVO.BidEndDate = this.BidDateRange[1];
        } else {
            this.queryReqVO.BidStartDate = 0;
            this.queryReqVO.BidEndDate = 0;
        }
    }

    // 处理下达日期
    private handleDirectDate(): void {
        if (this.directDate) {
            this.queryReqVO.directDateStart = this.directDate[0];
            this.queryReqVO.directDateEnd = this.directDate[1];
        } else {
            this.queryReqVO.directDateStart = 0;
            this.queryReqVO.directDateEnd = 0;
        }
    }

    // 按钮操作
    private handleButton(type: string): void {
        if (type === 'search') {
            this.getBidTableData(1);
        } else if (type === 'reset') {
            this.queryReqVO = JSON.parse(JSON.stringify(this.queryReqVOModal));
            this.BidDateRange = [];
            this.directDate = [];
        } else {
        }
    }

    private getDataTime(row): string {
        return moment(row.directDate + ' ' + PrefixInteger(row.directTime, 6), 'YYYYMMDD HHmmss').format('YYYY-MM-DD HH:mm:ss');
    }

    // 修改投标返回操作
    private bidDetailReturn(): void {
        this.updateRowShow = false;
    }

    // 设置是否禁用
    private handleDisabled(row: string): boolean {
        return !(row['instructionStatus'] == '1' && row['auth']);
    }

    // 获取债券代码下拉框数据
    getBondCodeList(e: string) {
        this.selectLoading = true;
        this.$axios
            .post('/dict/bond/select', {
                dictKey: e,
                dictKeyName: e,
            })
            .then((res: any) => {
                this.bondCodeSelectData = res || [];
                if (this.bondCodeSelectData.length > 0) {
                    this.bondCodeSelectData.unshift({
                        dictKey: '-1',
                        dictKeyName: '全部选择',
                    });
                }
                this.selectLoading = false;
            });
    }

    // 获取发行人代码下拉框数据
    getIssueCodeList(e: string) {
        this.selectLoading = true;
        this.$axios
            .post('/dict/issue/select', {
                dictKey: e,
                dictKeyName: e,
            })
            .then((res: any) => {
                this.issueCodeSelectData = res || [];
                if (this.issueCodeSelectData.length > 0) {
                    this.issueCodeSelectData.unshift({
                        dictKey: '-1',
                        dictKeyName: '全部选择',
                    });
                }
                this.selectLoading = false;
            });
    }

    // 处理
    handleIssueCodeList(list: any) {
        if (list.length > 0) {
            if (list[0] == '-1' && list.length > 1) {
                this.yh_message_warn('全选后不能勾选其他的数据');
                this.queryReqVO.issueCode = ['-1'];
            } else if (list[list.length - 1] == '-1' && list.length > 1) {
                this.queryReqVO.issueCode = ['-1'];
                this.yh_message_info('已全选');
            }
        }
    }

    // 处理
    handleBondCodeList(list: any) {
        if (list.length > 0) {
            if (list[0] == '-1' && list.length > 1) {
                this.yh_message_warn('全选后不能勾选其他的数据');
                this.queryReqVO.bondCode = ['-1'];
            } else if (list[list.length - 1] == '-1' && list.length > 1) {
                this.queryReqVO.bondCode = ['-1'];
                this.yh_message_info('已全选');
            }
        }
    }

    // 多选框返回值
    private customSelectReturn(value: any[], name: string): void {
        switch (name) {
            case 'issueCode':
                this.queryReqVO.issueCode = value;
                break;
            case 'fundCode':
                this.queryReqVO.fundCode = value;
                break;
            case 'bondCode':
                this.queryReqVO.bondCode = value;
                break;
            case 'userName':
                this.queryReqVO.userName = value;
                break;
        }
    }

    // 发行人性质转义
    dataRander(row): string {
        switch (row.issueNature) {
            case '001001':
                return '国有企业';
            case '001002':
                return '民营企业';
            case '001006':
                return '中资企业';
            case '002001':
                return '外资企业';
            case '003001':
                return '中外合资企业';
            case ' ':
                return '--';
            default:
                return '其他';
        }
    }
}
</script>
<style lang="scss" scoped>
#check-result {
    min-width: 1100px;
    padding: 10px;
    span {
        color: #333333;
    }
    .main {
        border: 1px solid #ccc;
        margin-top: 10px;
    }
    .main-bottom {
        margin-top: 10px;
        border: 1px solid #ccc;
    }
    .borderStyle {
        border: 1px solid #ccc;
    }

    /deep/ .el-form-item {
        margin-bottom: 10px;
    }
}

/deep/.el-table {
    th {
        padding: 5px 0 !important;
        background-color: #e8f3ff !important;
        .cell {
            white-space: nowrap; /* 文本在一行显示，不换行 */
            text-overflow: ellipsis; /* 显示省略符号来代表被修剪的文本。*/
            overflow: hidden; /* 超出部分隐藏 */
        }
    }
}

/deep/ .el-pagination {
    padding: 5px !important;
}

/deep/ .el-range-editor.is-active,
.el-range-editor.is-active:hover {
    border-color: #107fff;
}

/deep/ .el-select__tags {
    flex-wrap: nowrap;
}

/deep/ span.el-tag.el-tag--info.el-tag--mini.el-tag--light {
    display: flex;
    align-items: center;
    .el-select__tags-text {
        display: inline-block;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
</style>
